/*
 * Copyright (c) 2018. QDU 2015 Java1 Team CompilationError
 */

package team.mai.antexpress.entities;

import javax.persistence.*;
import java.util.Objects;

@Entity
@Table(name = "users", schema = "antexpress", catalog = "")
public class UserEntity {
	private int id;
	private String username;
	private String password;
	private String gender;
	private int departmentId;
	private int designationId;
	private int permissionGroupId;
	private String mobile;
	private String email;
	private int salary;

	public UserEntity(String username, String password, String gender, int departmentId, int designationId, int permissionGroupId, String mobile, String email, int salary) {
		this.username = username;
		this.password = password;
		this.gender = gender;
		this.departmentId = departmentId;
		this.designationId = designationId;
		this.permissionGroupId = permissionGroupId;
		this.mobile = mobile;
		this.email = email;
		this.salary = salary;
	}

	public UserEntity() {
	}

	@Id
	@Column(name = "id", nullable = false)
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Basic
	@Column(name = "username", nullable = false, length = 32)
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Basic
	@Column(name = "password", nullable = false, length = 32)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Basic
	@Column(name = "gender", nullable = false, length = 1)
	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	@Basic
	@Column(name = "department_id", nullable = false)
	public int getDepartmentId() {
		return departmentId;
	}

	public void setDepartmentId(int departmentId) {
		this.departmentId = departmentId;
	}

	@Basic
	@Column(name = "designation_id", nullable = false)
	public int getDesignationId() {
		return designationId;
	}

	public void setDesignationId(int designationId) {
		this.designationId = designationId;
	}

	@Basic
	@Column(name = "permission_group_id", nullable = false)
	public int getPermissionGroupId() {
		return permissionGroupId;
	}

	public void setPermissionGroupId(int permissionGroupId) {
		this.permissionGroupId = permissionGroupId;
	}

	@Basic
	@Column(name = "mobile", nullable = false, length = 11)
	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	@Basic
	@Column(name = "email", nullable = false, length = 64)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Basic
	@Column(name = "salary", nullable = false)
	public int getSalary() {
		return salary;
	}

	public void setSalary(int salary) {
		this.salary = salary;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		UserEntity that = (UserEntity) o;
		return id == that.id &&
				departmentId == that.departmentId &&
				designationId == that.designationId &&
				permissionGroupId == that.permissionGroupId &&
				salary == that.salary &&
				Objects.equals(username, that.username) &&
				Objects.equals(password, that.password) &&
				Objects.equals(gender, that.gender) &&
				Objects.equals(mobile, that.mobile) &&
				Objects.equals(email, that.email);
	}

	@Override
	public int hashCode() {

		return Objects.hash(id, username, password, gender, departmentId, designationId, permissionGroupId, mobile, email, salary);
	}
}
